home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / mint / filesy~1 / mfs6011s.zoo / fsck / main.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-12-31  |  1.9 KB  |  136 lines

  1. /* This File is part of 'fsck' copyright S.N. Henson */
  2.  
  3. #define EXTERN /**/
  4.  
  5. #include <stdio.h>
  6. #include <stdlib.h>
  7. #include <string.h>
  8. #include <unistd.h>
  9.  
  10. #include "fs.h"
  11. #include "global.h"
  12. #include "proto.h"
  13.  
  14. void main(argc,argv)
  15. int argc;
  16. char **argv;
  17. {
  18.     int rw;
  19.     int c;
  20.     extern void do_fsck1(),do_fsck2();
  21.  
  22.     extern int optind,opterr;
  23.     extern char *optarg;
  24.  
  25.     if(!__mint)
  26.     {
  27.         fprintf(stderr,"Fatal: MiNT not active\n");
  28.         exit(1);
  29.     }
  30.  
  31.     rw=1;
  32.     opterr=0;
  33.     while( (c=getopt(argc,argv,"pyYnNd:D:sSRi:z:e"))!=EOF )
  34.     {
  35.         switch(c)
  36.         {
  37.             case 'y':
  38.             case 'Y':
  39.             ally=1;
  40.             break;
  41.             
  42.             case 'n':
  43.             case 'N':
  44.             rw=0;
  45.             alln=1;
  46.             break;
  47.  
  48.             case 'd':
  49.             case 'D':
  50.             incr=atoi(optarg);
  51.             if( (incr<1) || (incr>8) || NPOW2(incr))
  52.             {
  53.                 fprintf(stderr,"Invalid Increment Value\n");
  54.                 exit(1);
  55.             }
  56.             break;
  57.  
  58.             case 's':
  59.             info=1;
  60.             break;
  61.  
  62.             case 'S':
  63.             info=2;
  64.             break;
  65.  
  66.             case 'R':
  67.             badroot=1;
  68.             break;
  69.  
  70.             case 'i':
  71.             comma_parse(optarg,&inums);
  72.             break;
  73.  
  74.  
  75.             case 'z':
  76.             comma_parse(optarg,&zinums);
  77.             break;
  78.  
  79. #if notyet
  80.             case 'u':
  81.             ul=malloc(sizeof(llist));
  82.             if(!ul) fatal("Out of Memory");
  83.             ul->member=(long)strdup(optarg);
  84.             ul->next=unlist;
  85.             unlist=ul;
  86.             break;
  87. #endif
  88.  
  89.             case 'p':
  90.             preen=1;
  91.             break;
  92.  
  93.             case 'e':
  94.             no_size=1;
  95.             break;
  96.  
  97.             case '?':
  98.             usage();
  99.             break;        
  100.         }
  101.     }
  102.  
  103.     if( (argc-optind!=1) || opterr) usage();
  104.  
  105.     if(preen && (ally || alln))
  106.     {
  107.         fprintf(stderr,"-p option cannot be mixed with -n or -y\n");
  108.         exit(1);
  109.     }
  110.  
  111.     if(preen) ally=1;
  112.  
  113.     if(badroot && !incr)
  114.     {
  115.         fprintf(stderr,"'-R' option needs '-d'\n");
  116.         exit(1);
  117.     } 
  118.  
  119.     drvnam=strdup(argv[optind]);
  120.  
  121.     if( init_device(argv[optind],rw))
  122.     {
  123.         fprintf(stderr,"Can't Open Device %s\n",argv[optind]);
  124.         exit(1);
  125.     }
  126.  
  127.     read_tables();
  128.  
  129.     if(version) do_fsck2();
  130.     else do_fsck1();
  131.  
  132.     showinfo();
  133.     close_device();
  134.     exit(0);
  135. }
  136.